package com.siao.example.libaray.component.view
{
	import com.siao.component.Orientation;
	import com.siao.component.scroller.ScrollBar;
	import com.siao.component.scroller.ScrollList;
	import com.siao.data.ArrayList;
	import com.siao.display.Align;
	import com.siao.example.common.ui.Layer;
	import com.siao.example.libaray.component.ui.ListItem;
	import com.siao.mvc.View;
	
	import flash.display.Sprite;
	
	/**
	 * 滚动列表视图
	 * @author SiaoLeon
	 */
	public class ComponentScrollListView extends View
	{
		// -------------------------------------------------------------------------------------------------------- 静态常量
		
		// -------------------------------------------------------------------------------------------------------- 静态变量
		
		// -------------------------------------------------------------------------------------------------------- 静态方法
		
		// -------------------------------------------------------------------------------------------------------- 静态函数
		
		// -------------------------------------------------------------------------------------------------------- 属性
		
		// -------------------------------------------------------------------------------------------------------- 变量
		
		private var scrollList:ScrollList;
		
		// -------------------------------------------------------------------------------------------------------- 构造
		
		/**
		 * 构造函数
		 */
		public function ComponentScrollListView()
		{
			super();
			
			var data:ArrayList = new ArrayList();
			
			for (var i:int = 0; i < 10; i++)
			{
				data.add(i);
			}
			
			//生成垂直滚动条
			var backgroundV:Sprite = new Sprite();
			backgroundV.graphics.beginFill(0X000000, 0.8);
			backgroundV.graphics.drawRect(0, 0, 12, 100);
			backgroundV.graphics.endFill();
			
			var dragV:Sprite = new Sprite();
			dragV.graphics.beginFill(0XFF0000, 1);
			dragV.graphics.drawRect(0, 0, 20, 40);
			dragV.graphics.endFill();
			
			var prevV:Sprite = new Sprite();
			prevV.graphics.beginFill(0XFF0000, 0.8);
			prevV.graphics.drawRect(0, 0, 20, 20);
			prevV.graphics.endFill();
			
			var nextV:Sprite = new Sprite();
			nextV.graphics.beginFill(0XFF0000, 0.8);
			nextV.graphics.drawRect(0, 0, 20, 20);
			nextV.graphics.endFill();
			
			var vScrollBar:ScrollBar = new ScrollBar(Orientation.VERTICAL, backgroundV, dragV, prevV, nextV);
			
			//生成水平滚动条
			var backgroundH:Sprite = new Sprite();
			backgroundH.graphics.beginFill(0X000000, 0.8);
			backgroundH.graphics.drawRect(0, 0, 100, 12);
			backgroundH.graphics.endFill();
			
			var dragH:Sprite = new Sprite();
			dragH.graphics.beginFill(0XFF0000, 1);
			dragH.graphics.drawRect(0, 0, 40, 20);
			dragH.graphics.endFill();
			
			var prevH:Sprite = new Sprite();
			prevH.graphics.beginFill(0XFF0000, 0.8);
			prevH.graphics.drawRect(0, 0, 20, 20);
			prevH.graphics.endFill();
			
			var nextH:Sprite = new Sprite();
			nextH.graphics.beginFill(0XFF0000, 0.8);
			nextH.graphics.drawRect(0, 0, 20, 20);
			nextH.graphics.endFill();
			
			var hScrollBar:ScrollBar = new ScrollBar(Orientation.HORIZONTAL, backgroundH, dragH, prevH, nextH);
			
			this.scrollList = new ScrollList(Orientation.TOP_BOTTOM, Orientation.LEFT_RIGHT, vScrollBar, hScrollBar);
			this.scrollList.draw(0X000000, 0.2);
			this.scrollList.width = 300;
			this.scrollList.height = 400;
			this.scrollList.x = 80;
			this.scrollList.y = 110;
			this.scrollList.padding = 10;
			this.scrollList.rowSpacing = this.scrollList.colSpacing = 2;
			this.scrollList.contentAlignV = Align.TOP;
			this.scrollList.maskMarginLeft = 5;
			this.scrollList.maskMarginRight = 15;
			this.scrollList.maskMarginBottom = 10;
			this.scrollList.scrollWheel = true;
			this.scrollList.scrollEasing = true;
			this.scrollList.scrollDrag = true;
			this.scrollList.scrollDrag = true;
			//			this.scrollList.wrap = true;
			this.scrollList.overDrag = 100;
			this.scrollList.bind(ListItem, data);
		}
		
		// -------------------------------------------------------------------------------------------------------- 方法
		
		override public function onAdd():void
		{
			Layer.instance.content.addChild(this.scrollList);
		}
		
		override public function onRemove():void
		{
			Layer.instance.content.removeChild(this.scrollList);
		}
	
		// -------------------------------------------------------------------------------------------------------- 函数
	
	}
}
